/*
 * Sesame Inc.
 * Copyright (c) 2009 All Rights Reserved.
 */
package com.sesame.daoimpl;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.sesame.dao.FriendDAO;
import com.sesame.domain.Friend;

/**
 * @author voidman
 * 
 */
public class FriendDAOImpl extends SqlMapClientDaoSupport implements FriendDAO {

    public void addFriend(Friend friend) {
        getSqlMapClientTemplate().insert("addFriend", friend);
    }

    public void deleteFriendByUserId(Friend friend) {
        getSqlMapClientTemplate().delete("deleteFriendByUserId", friend);
    }

    public void deleteFriendByReceiverId(Integer receiverId) {
        getSqlMapClientTemplate()
                .delete("deleteFriendByReceiverId", receiverId);
    }

    public List<Friend> getAllFriend(Integer senderId) {
        return getSqlMapClientTemplate().queryForList("getAllFriend", senderId);
    }

    public List<Friend> getTopFriend(Integer senderId) {
        return getSqlMapClientTemplate().queryForList("getTopFriend", senderId);
    }

    public Friend getFriendById(Integer id) {
        return (Friend) getSqlMapClientTemplate().queryForObject(
                "getFriendById", id);
    }

    public Integer getFriendByUserId(Friend friend) {
        return (Integer) getSqlMapClientTemplate().queryForObject(
                "getFriendByUserId", friend);
    }

    public void updateFriend(Friend friend) {
        getSqlMapClientTemplate().update("updateFriend", friend);
    }

}